
Blockly.defineBlocksWithJsonArray([{
  "type": "date_block",
  "message0": "%1年 %2月 %3日",
  "args0": [
  {
      "type": "input_value",
      "name": "YEAR",
      "min": 2019,
      "max": 2099,
      "value": 2020,
      "check": "Number"
  },
  {
      "type": "input_value",
      "name": "MONTH",
      "min": 1,
      "max": 12,
      "value": 1,
      "check": "Number"
  },
  {
      "type": "input_value",
      "name": "DAY",
      "min": 1,
      "max": 31,
      "value": 1,
      "check": "Number"
  }
  ],
  "inputsInline": true,
  "output": "Number",
  "colour": "%{BKY_LOOPS_HUE}"
}]);





Blockly.Lua['date_block'] = function(block) {

  var year =   Blockly.Lua.valueToCode(block, 'YEAR', Blockly.Lua.ORDER_NONE) || '2020'; 
  var month = Blockly.Lua.valueToCode(block, 'MONTH', Blockly.Lua.ORDER_NONE) || '1';
  var day =  Blockly.Lua.valueToCode(block, 'DAY', Blockly.Lua.ORDER_NONE) || '1';
  
  if(month<10){
    month = '0'+ month;
  }

  if(day < 10){
    day = '0'+ day;
  }
  var code = year + month + day;
  
  var order = Blockly.Lua.ORDER_NONE; 
  return [code,order];
};

